package com.example.a10_2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button = (Button) findViewById(R.id.home_button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();//创建Intent类
                intent.setAction(Intent.ACTION_MAIN);//设置Intent动作，作为初始的Activity启动
                intent.addCategory(Intent.CATEGORY_HOME);//设置Intent种类，为回到Home界面
                startActivity(intent);//将Intent传递给Activity
            }
        });
    }
}